package com.qian.ddj.web.controller;

import com.qian.api.ddj.model.SHCategory;
import com.qian.api.ddj.service.ISHCategoryService;
import com.yaowk.api.common.PageReq;
import com.yaowk.api.common.PageResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/ddj/SHcategory")
@Api(tags = "商户报件分类")
public class SHCategoryController {
    @Autowired
    private ISHCategoryService shCategoryService;

    @PostMapping
    @ApiOperation("保存或修改")
    public void save(SHCategory shCategory) {
        shCategoryService.saveOrUpdate(shCategory);

    }

    @GetMapping("/{id}")
    @ApiOperation("通过ID查询")
    public SHCategory findById(@PathVariable Integer id) {
        SHCategory shCategory = shCategoryService.findById(id);
        return shCategory;
    }
    @DeleteMapping("/delete/{id}")
    @ApiOperation("通过ID删除")
    public void delete(@PathVariable Integer id){
        shCategoryService.delete(shCategoryService.findById(id));
    }
    @GetMapping("/all")
    @ApiOperation("查询所有")
    public PageResp<SHCategory> findAll(PageReq pageReq){
        PageResp<SHCategory> pageResp = shCategoryService.findAll(pageReq);
        return pageResp;
    }
}
